Skip to content

helpers: add arm64 Metal3 image builder#77

Merged
openshift-merge-bot[bot] merged 3 commits into
openshift-eng:mainfrom
fonta-rh:helpers/build-metal3-arm64
Jun 16, 2026
Merged

helpers: add arm64 Metal3 image builder#77
openshift-merge-bot[bot] merged 3 commits into
openshift-eng:mainfrom
fonta-rh:helpers/build-metal3-arm64

Conversation

@fonta-rh

@fonta-rh fonta-rh commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds helpers/build-metal3-arm64.sh — a script that builds arm64 variants of the Metal3 container images (ironic, vbmc, sushy-tools) from upstream metal3-io/ironic-image source
  • Upstream only publishes amd64 images to quay.io, which blocks running dev-scripts on aarch64 hypervisors (e.g., AWS Graviton instances at 33-40% lower cost)
  • Supports native builds on aarch64 hosts and cross-builds via QEMU from x86_64
  • Defaults to pushing to quay.io/rh-edge-enablement/ but namespace/registry are configurable

Usage

# Build all 3 images and push (defaults to quay.io/rh-edge-enablement)
./helpers/build-metal3-arm64.sh

# Build from a release tag with date-based tag
./helpers/build-metal3-arm64.sh --ref v28.0.0 --tag 2026-06

# Build only one image, don't push
./helpers/build-metal3-arm64.sh --images sushy-tools --no-push

Then in dev-scripts config_<user>.sh:

export IRONIC_IMAGE=quay.io/rh-edge-enablement/ironic:2026-06
export VBMC_IMAGE=quay.io/rh-edge-enablement/vbmc:2026-06
export SUSHY_TOOLS_IMAGE=quay.io/rh-edge-enablement/sushy-tools:2026-06

Context

The Metal3 team completed multi-arch bare metal support (METAL-1226/1545) for OCP 4.22, but that effort focused on provisioning arm64 nodes from x86 clusters — the container images themselves are still amd64-only. The ironic-image Dockerfile and PR CI already build for arm64, but the push/release workflows don't pass multi-platform flags to the shared build infrastructure. Until that's wired up upstream, this script provides a self-service workaround.

Test plan

  • Verified shellcheck passes
  • Built all 3 images via cross-build (QEMU on x86_64)
  • Pushed to quay.io/rh-edge-enablement/{ironic,vbmc,sushy-tools}:2026-06
  • Verified images on quay.io are arm64 architecture via skopeo inspect
  • End-to-end: run dev-scripts IPI on Graviton with these images

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added support to build and optionally push ARM64 container images for Metal3 components, including cross-platform builds via emulation.
    • Included optional registry authentication and an automated build-and-push workflow, with configurable parameters and temporary source cleanup.
  • Documentation / UX Improvements
    • Updated OpenShift deployment messaging to consistently provide “next steps” for proxy environment setup and cluster access via a shared helper.

@openshift-ci openshift-ci Bot requested review from eggfoobar and qJkee June 5, 2026 12:56
@openshift-ci

openshift-ci Bot commented Jun 5, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: fonta-rh

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@coderabbitai

coderabbitai Bot commented Jun 5, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: c6340ca0-11dd-4937-96b0-cd513f33d411

📥 Commits

Reviewing files that changed from the base of the PR and between 0561983 and 14507be.

📒 Files selected for processing (5)
  • deploy/aws-hypervisor/scripts/common.sh
  • deploy/openshift-clusters/scripts/deploy-cluster.sh
  • deploy/openshift-clusters/scripts/redeploy-cluster.sh
  • deploy/openshift-clusters/scripts/startup-cluster.sh
  • helpers/build-metal3-arm64.sh
🚧 Files skipped from review as they are similar to previous changes (1)
  • helpers/build-metal3-arm64.sh

Walkthrough

A new Bash script adds arm64 container image build capability for Metal3 (ironic, vbmc, sushy-tools). The script accepts configurable registry, namespace, ref, tag, and image selection via command-line options, validates prerequisites, prepares build sources via clone or existing checkout, builds images with cross-platform flags, and optionally pushes results while exporting environment variables for downstream consumption. In parallel, repeated post-deployment proxy setup instructions are consolidated into a shared helper function used across three cluster deployment scripts.

Changes

Metal3 arm64 Image Build Script

Layer / File(s) Summary
Script initialization and CLI parsing
helpers/build-metal3-arm64.sh
Script sets strict Bash options, defines defaults for registry, namespace, ref, tag, and image list. Provides ANSI color codes and logging utilities. Implements complete command-line argument parsing supporting registry, namespace, ref, tag, image selection, plus --no-push, --keep-source, and --source-dir options with comprehensive help text and error handling.
Prerequisites validation and source management
helpers/build-metal3-arm64.sh
Validates podman and git availability. Detects host architecture and verifies QEMU binfmt support for non-aarch64 cross-compilation. Enforces podman registry authentication when push is enabled. Prepares build source by cloning metal3-io/ironic-image at requested ref or validating and reusing an existing checkout with logged commit hashes. Installs EXIT trap for automatic cleanup of temporary sources.
Image build and push operations
helpers/build-metal3-arm64.sh
Maps image names to corresponding Dockerfile directories. Constructs fully qualified image tags from registry/namespace/tag configuration. Conditionally adds --platform linux/arm64 for non-aarch64 hosts to enable QEMU-based cross-compilation. Executes podman build and podman push with error reporting and logging.
Main orchestration and result handling
helpers/build-metal3-arm64.sh
Main function logs configuration, parses comma-separated image list, and iterates over requested images calling build and optional push for each. Accumulates failures across all images and exits non-zero if any failed. Outputs environment variable export lines mapping IRONIC_IMAGE, VBMC_IMAGE, and SUSHY_TOOLS_IMAGE to fully qualified image tags.

Proxy Instructions Consolidation

Layer / File(s) Summary
Shared proxy instructions helper
deploy/aws-hypervisor/scripts/common.sh
New print_proxy_instructions() function outputs standardized post-setup guidance: sourcing the proxy environment from openshift-clusters/proxy.env, verifying cluster access via oc get nodes, and accessing the cluster console.
Integration with deployment scripts
deploy/openshift-clusters/scripts/deploy-cluster.sh, deploy/openshift-clusters/scripts/redeploy-cluster.sh, deploy/openshift-clusters/scripts/startup-cluster.sh
Replace hardcoded multi-line "Next steps" echo blocks with calls to print_proxy_instructions, removing duplicated proxy.env sourcing and cluster access verification instructions.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~28 minutes

🚥 Pre-merge checks | ✅ 9 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Ai-Attribution ⚠️ Warning PR explicitly mentions AI-generated code ("Generated with Claude Code") but commits use Co-Authored-By trailer instead of required Generated-by or Assisted-by Red Hat attribution. Replace Co-Authored-By: Claude Opus 4.6 trailer with Generated-by or Assisted-by trailer for proper Red Hat AI attribution per policy.
✅ Passed checks (9 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding a new arm64 Metal3 image builder script to the helpers directory.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
No-Weak-Crypto ✅ Passed The PR adds a bash script for building Metal3 images and utility functions. No weak cryptographic algorithms (MD5, SHA1, DES, RC4, 3DES, Blowfish, ECB), custom crypto implementations, hardcoded sec...
Container-Privileges ✅ Passed PR contains only shell scripts for deployment automation; no Kubernetes manifests or container security policies with privilege flags are present.
No-Sensitive-Data-In-Logs ✅ Passed No sensitive data logging found. Script logs only public image URLs, registry names, git refs, and build status—no passwords, tokens, API keys, PII, or session IDs are exposed in logs or echo state...
No-Hardcoded-Secrets ✅ Passed No hardcoded secrets, API keys, tokens, passwords, private keys, base64 strings, or embedded credentials found in any modified or new files.
No-Injection-Vectors ✅ Passed No injection vectors found. All user-controlled variables are properly quoted in command execution (git/podman), and no eval/exec/pickle/yaml.load/os.system/shell=True patterns detected.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

@openshift-ci openshift-ci Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 5, 2026
@coderabbitai coderabbitai Bot added the ready-for-human-review Indicates a PR has been reviewed by automated tools and is ready for human review label Jun 5, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@helpers/build-metal3-arm64.sh`:
- Around line 235-239: The EXIT trap registration is placed after prepare_source
so a failure inside prepare_source can leave temp files; move the trap setup
earlier by invoking the trap command for cleanup_source (trap cleanup_source
EXIT) immediately after check_prerequisites and before calling prepare_source so
cleanup_source will run even if prepare_source fails.
- Around line 142-150: When --source-dir is provided the script sets WORK_DIR
from SOURCE_DIR but never enforces the requested Git ref (REF), allowing the
build to run from whatever HEAD is present while logs still show "Git ref:
${REF}"; update the logic after setting WORK_DIR to validate and enforce REF by
changing into WORK_DIR, fetching updates and attempting to checkout the
requested REF (or exit with an error if checkout fails), or at minimum compare
the current HEAD to REF and fail if they differ — touch the block that
references SOURCE_DIR, WORK_DIR and REF to perform the git fetch/git checkout or
HEAD validation so the build actually uses the requested --ref.
- Around line 155-158: The current check compares the literal HEAD output to the
ref name, causing false positives; replace it by resolving the target ref to a
commit and comparing commit hashes: run current_rev=$(git -C "${WORK_DIR}"
rev-parse HEAD) and target_rev=$(git -C "${WORK_DIR}" rev-parse --verify
"${REF}" 2>/dev/null) then only run git fetch/checkout when target_rev is empty
or current_rev != target_rev; update the block that references WORK_DIR and REF
to use these variables so fetch/checkout only occurs when the commit actually
differs.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: 9b922afd-5b0e-4db6-9f0b-ae78dc77a775

📥 Commits

Reviewing files that changed from the base of the PR and between 88ef77a and 1f3a303.

📒 Files selected for processing (1)
  • helpers/build-metal3-arm64.sh

Comment thread helpers/build-metal3-arm64.sh
Comment thread helpers/build-metal3-arm64.sh Outdated
Comment thread helpers/build-metal3-arm64.sh Outdated

@lucaconsalvi lucaconsalvi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work, Pablo — this fills a real gap for running dev-scripts on Graviton instances. Clean script, great PR description, honest test plan.

One thing I noticed:

Ref resolution check (L155)

if [[ "$(git -C "${WORK_DIR}" rev-parse HEAD 2>/dev/null)" != *"${REF}"* ]]; then

This compares a full SHA against the ref name via substring match — a SHA will almost never contain main or v28.0.0, so the condition is always true. The fetch + checkout runs every time, even when the --branch clone already succeeded. Doesn't produce wrong builds, but adds unnecessary network calls on every run.

Note: the always-true conditional accidentally makes the fallback path work (when --branch fails and the full clone lands on the default branch), so a fix needs to handle both cases:

if ! git -C "${WORK_DIR}" rev-parse --verify "${REF}^{commit}" >/dev/null 2>&1; then
    git -C "${WORK_DIR}" fetch origin "${REF}" 2>&1
fi
git -C "${WORK_DIR}" checkout "${REF}" 2>&1

Otherwise LGTM — solid script.

@coderabbitai coderabbitai Bot removed the ready-for-human-review Indicates a PR has been reviewed by automated tools and is ready for human review label Jun 12, 2026
@openshift-ci openshift-ci Bot added the ready-for-human-review Indicates a PR has been reviewed by automated tools and is ready for human review label Jun 12, 2026
@fonta-rh fonta-rh force-pushed the helpers/build-metal3-arm64 branch from 7790e7e to 0561983 Compare June 16, 2026 08:30
@coderabbitai coderabbitai Bot removed the ready-for-human-review Indicates a PR has been reviewed by automated tools and is ready for human review label Jun 16, 2026
fonta-rh and others added 3 commits June 16, 2026 10:34
Upstream metal3-io only publishes amd64 container images for ironic,
vbmc, and sushy-tools. This blocks running dev-scripts on aarch64
hypervisors (e.g., AWS Graviton).

Add a helper script that builds arm64 variants from the same
ironic-image source and pushes them to a registry you control.
Supports native builds on aarch64 hosts and cross-builds via QEMU
from x86_64.

Assisted-by: Claude (Anthropic)
- Fix broken ref check: replace SHA-vs-name substring match with
  rev-parse --verify to only fetch/checkout when the ref isn't already
  available locally
- Validate --source-dir against --ref: verify the checkout is a git repo
  and HEAD matches the requested ref
- Move EXIT trap before prepare_source so temp dirs are cleaned up on
  failure

Assisted-by: Claude (Anthropic)
All lifecycle scripts (deploy, redeploy, startup) now call a common
function for the post-operation "source proxy.env" message. Also adds
the missing proxy instructions to startup-cluster.sh.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@fonta-rh fonta-rh force-pushed the helpers/build-metal3-arm64 branch from 0561983 to 14507be Compare June 16, 2026 08:46
@lucaconsalvi

Copy link
Copy Markdown
Contributor

/lgtm

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Jun 16, 2026
@openshift-merge-bot openshift-merge-bot Bot merged commit fdf5f39 into openshift-eng:main Jun 16, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants